package ClassAndObject.Object_Objects;

import java.util.Objects;

public class Demo03Objects {
    public static void main(String[] args) {
        String o = null;
        String o1 = "aaf";
/*
Objects类的equals方法避免了空指针异常
public static boolean equals(Object a, Object b) {
        return (a == b) || (a != null && a.equals(b));
    }
*/
        boolean equals = Objects.equals(o, o1);
        System.out.println(equals);
    }
}
